//
// Created by 紫霄 on 2020/4/17.
//

#ifndef LEETCODE_21_H
#define LEETCODE_21_H
#include <vector>
using namespace std;
class Solution {
public:
  vector<int> exchange(vector<int> &nums) {
    vector<int> oddSeq;
    vector<int> evenSeq;
    int sz = nums.size();
    int seqBack = sz - 1;
    for (int seq = 0; seq < sz; ++seq) {
      if (seq == seqBack) {
        return nums;
      }
      if (nums[seq] % 2 == 0) {
        while (nums[seqBack] % 2 == 0) {
          --seqBack;
          if (seqBack == seq) {
            return nums;
          }
        }
        swap(nums[seq], nums[seqBack]);
      }
    }
    return nums;
  }
};
#endif // LEETCODE_21_H
